<template>
  <view class="webview-container">
    <web-view 
      :src="url" 
      @message="handleMessage"
      @onPostMessage="handlePostMessage"
    ></web-view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      url: ''
    }
  },
  onLoad(options) {
    // 获取传递过来的url参数并解码
    if (options.url) {
      this.url = decodeURIComponent(options.url)
    }
  },
  methods: {
    handleMessage(event) {
      // 处理web-view发送的消息
      console.log('收到web-view消息:', event.detail)
    },
    handlePostMessage(event) {
      // 处理web-view的postMessage
      console.log('收到postMessage:', event.detail)
    }
  }
}
</script>

<style lang="scss" scoped>
.webview-container {
  width: 100%;
  height: 100vh;
}
</style> 